// ssoStrategies.js
const ssoStrategies = {
  companyA: {
    name: 'A公司',
    getTicket: function () {
      return new Promise((resolve, reject) => {
        try {
          const ticket = window.A.API.ssoTicket({}); // 同步或异步都行
          resolve(ticket);
        } catch (e) {
          reject(e);
        }
      });
    }
  },
  companyB: {
    name: 'B公司',
    getTicket: function () {
      return new Promise((resolve, reject) => {
        // console.log(111);
        // var a=12
        // if(a){
        //   resolve()
        // }
        // reject
        window.lightAppJssdk.user.getTicketNew({
          success: function (data) {
            console.log("登录状态",data);

            if (data === '未登录') {
              reject(new Error('未登录'));
            } else {
              try {
                const userInfo = JSON.parse(data);
                resolve(userInfo);
              } catch (e) {
                reject(new Error('解析失败'));
              }
            }
          },
          fail: function () {
            reject(new Error('获取ticket失败'));
          }
        });
      });
    }
  },

  // 后续新增公司C，直接加在这里
  companyC: {
    name: 'C公司',
    getTicket: function () {
      return new Promise((resolve, reject) => {
        // C公司自己的逻辑
       window.C.API.getToken({
          onSuccess: resolve,
          onError: reject
        });
      });
    }
  }
};

export default ssoStrategies;